<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="ot" uri="http://www.ideyatech.com/tides"%>
<%@ taglib prefix="idy" tagdir="/WEB-INF/tags"%>

<idy:bs-iris-header title_webpage="title.admin.patient">
	
</idy:bs-iris-header>

<div class="page-body">
	<div class="admin-search-box">
		<form:form id="patientSearchForm" commandName="patient" action="${url_context}/patients.jspx" cssClass="form-horizontal">

			<div class="form-box-title"><h4><spring:message code="label.admin.patient.search"/></h4></div>

			<div class="control-group">
				<label class="control-label"><spring:message code="label.admin.patient.firstName" /></label>
				<div class="controls">
					<form:input path="firstName" maxlength="50"/>
				</div>
			</div>
			<div class="control-group">
				<label class="control-label"><spring:message code="label.admin.patient.lastName" /></label>
				<div class="controls">
					<form:input path="lastName" maxlength="50"/>
				</div>
			</div>
			<div class="control-group">
				<label class="control-label"><spring:message code="label.admin.patient.nickname" /></label>
				<div class="controls">
					<form:input path="nickname" maxlength="50"/>
				</div>
			</div>
			<div class="control-group">
				<div class="controls">
					<input type="submit" class="btn btn-primary"name="Submit_" value="<spring:message code="label.submit" />" />
			    	<input type="button" class="btn" name="clear" value="Clear" id="search-clear"/>
				</div>
			</div>
			<ot:sort_input searchFormId="patientSearchForm"/>
		</form:form>
	</div>
	
	<div id="patient-row-new"></div>
	<div class="pull-right">
		<ot:paging results="${results}" baseURL="${url_context}/patients.jspx" pageParamName="page" displaySummary="true" displayPageLinks="false" searchFormId="patientSearchForm"/>
	</div>
	<table class="table table-striped table-condensed table-bordered">
     	<thead>
     		<tr>
     			<th>
     				<ot:header_sort headerField="lastName" headerLabel="label.admin.patient.lastName" prefix="${patient}" searchFormId="patientSearchForm" />
     			</th>
     			<th>
     				<ot:header_sort headerField="firstName" headerLabel="label.admin.patient.firstName" prefix="${patient}" searchFormId="patientSearchForm" />
     			</th>
     			<th>
     				<ot:header_sort headerField="middleName" headerLabel="label.admin.patient.middleName" prefix="${patient}" searchFormId="patientSearchForm" />
     			</th>
     			<th>
     				<ot:header_sort headerField="nickname" headerLabel="label.admin.patient.nickname" prefix="${patient}" searchFormId="patientSearchForm" />
     			</th>
     			<th></th>
     		</tr>
     	</thead>
     	<tbody id="patient-table-results">
      		<c:forEach items="${results.results}" var="record" varStatus="status">
	      		<tr id="patient-row-${record.id}">
	      			<td>
	      				<c:out value="${record.lastName}" />
	      			</td>
	      			<td>
	      				<c:out value="${record.firstName}" />
	      			</td>
	      			<td>
	      				<c:out value="${record.middleName}" />
	      			</td>
	      			<td>
	      				<c:out value="${record.nickname}" />
	      			</td>
	          		<td>
						<a href="${url_context}/patient.jspx?id=${record.id}">View</a>                  		
	          		</td>	
	      		</tr>
      		</c:forEach>
     	</tbody>
	</table>
         	
	<div style="text-align: center;">
   		<ot:paging results="${results}" baseURL="${url_context}/patients.jspx" pageParamName="page" displaySummary="false" displayPageLinks="true" searchFormId="patientSearchForm"/>
   	</div>
</div>

<idy:bs-iris-footer>
	<script type="text/javascript">
		$(document).ready(function(){
			$('#search-clear').click(function(){
				IRIS.htmlUtil.clearSearchPane('patientSearchForm');
			});
		});
	</script>
</idy:bs-iris-footer>